﻿using System;
using System.Linq;
using HttpAuth.Bootstrap;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;

[assembly: System.Web.PreApplicationStartMethod(typeof(PreApplicationStart), "Start")]

namespace HttpAuth.Bootstrap
{
    public class PreApplicationStart
    {
        private static readonly object _lock = new object();
        private static bool _registered;

        public static void Start()
        {
            lock (_lock)
            {
                if (_registered) return;

                DynamicModuleUtility.RegisterModule(typeof(HttpAuthenticationModule));
                
                _registered = true;
            }
        }
    }
}
